package br.edu.ifrn.potigol.lang.nodes;

import br.edu.ifrn.potigol.lang.Context;
import br.edu.ifrn.potigol.lang.PotigolException;
import br.edu.ifrn.potigol.lang.PotigolObject;
import br.edu.ifrn.potigol.lang.PotigolArrayObject;
import br.edu.ifrn.potigol.lang.PotigolRuntime;

public class ArrayAssignNode extends Node {
	private String name;
	private ArrayNode arrayNode;
	
	public ArrayAssignNode(String name, ArrayNode arrayNode) {
		this.name = name;
		this.arrayNode = arrayNode;
	}

	@Override
	public PotigolObject eval(Context context) throws PotigolException {
		PotigolArrayObject potigolObjectArray = context.getArray(arrayNode.getName());
		context.setArray(name, potigolObjectArray);
		return PotigolRuntime.getNil();
	}

}
